class_name  TileMapGridInitializer
extends GridInitializer

##
@export var tile_map_layer: TileMapLayer

##
@export var target_source_id: int

##
@export var target_tile_set_coord : Vector2i


func get_grid() -> Array[Vector2i]:
	var grid: Array[Vector2i] = []
	for cell_pos in tile_map_layer.get_used_cells():
		var source_id = tile_map_layer.get_cell_source_id(cell_pos)
		var tile_set_coords = tile_map_layer.get_cell_atlas_coords(cell_pos)
		if source_id == target_source_id and tile_set_coords == target_tile_set_coord:
			grid.append(cell_pos)
	return grid
